package com.example.chenhaosblog.service.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.example.chenhaosblog.mapper.DaoSupport;
import com.example.chenhaosblog.service.RegisterService;
import com.example.chenhaosblog.utils.PageData;

@Service
public class RegisterServiceImpl implements RegisterService {
	@Resource(name = "daoSupport")
	private DaoSupport dao;

	@Override
	public void addRegister(PageData pageData) throws Exception {
		dao.save("RegisterMapper.insert", pageData);
	}
	
	@Override
	public void deleteUser(PageData pageData) throws Exception {
		String[] ids = pageData.getString("id").split(",");
		List<String> idList= new ArrayList<>(Arrays.asList(ids));
		dao.delete("RegisterMapper.updateStatu", idList);
	}

	@Override
	public void updateRegister(PageData pageData) throws Exception {
		 dao.update("RegisterMapper.updateUser",pageData);
	}
	
	@Override
	public List<PageData> userManageList(PageData pageData) throws Exception {
		return (List<PageData>) dao.findForList("RegisterMapper.queryList", pageData);
	}

	@Override
	public PageData findShow(PageData pageData) throws Exception {
		return (PageData)dao.findForObject("RegisterMapper.findShowInfo", pageData);
	}
	
	
	@Override
	public PageData selectRegister(PageData pageData) throws Exception {
		return (PageData)dao.findForObject("RegisterMapper.selectRegister", pageData);
	}
}
